/*
Web: http://www.jsForms.com
Copyright (C) 2008  Igor Demyanov (mailto:Igor.Demyanov@gmail.com)
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
jsForms.Components["common.Slider"] = {
		Init: function()
		{
			console.log(this._Name+':Slider.Init');
			return jsForms.Components.Component.Init.call(this);
		},
		SetMaxState: function(value)
		{
			this.P.MaxState = value;
			return this;
		},
		SetMinState: function(value)
		{
			this.P.MinState = value;
			return this;
		},
		SetSpeed: function(value)
		{
			this.P.Speed = value;
			return this;
		},
		Expand: function(){
			console.log(this._Name + ':Slider.Expand');
			this.P.isExpand = true;
			if (this.P.MaxState) {
				var targetObj = this;
				this.stop().animate(this.P.MaxState, this.P.Speed, function(){
					if (targetObj.E.onResize) {
						targetObj.E.onResize.func.call(targetObj.E.onResize.obj);
					}
				});
			/*this.css(this.Properties.MaxState);
			 if (this.Events.onResize) {
			 this.Events.onResize.func.call(this.Events.onResize.obj);
			 }*/
			}
		},
		Collapse:function()
		{
			console.log(this._Name+':Slider.Collapse');
			this.P.isExpand = false;
			if (this.P.MinState) {
				var targetObj = this;
				this.stop().animate(this.P.MinState, this.P.Speed, function(){
					if (targetObj.E.onResize) {
						targetObj.E.onResize.func.call(targetObj.E.onResize.obj);
					}
				});
			/*this.css(this.Properties.MinState);
			 if (this.Events.onResize) {
			 this.Events.onResize.func.call(this.Events.onResize.obj);
			 }*/
			}
		},
		Toggle:function()
		{
			console.log(this._Name+':Slider.Toggle');
			if (this.P.isExpand)
			{
				this.Collapse();
			}else
			{
				this.Expand();
			}
		}
		
	};
// -----------------------------------------------
// Compilation INFO
// -----------------------------------------------
jsForms.CreateCompileInfoByObject(
{
	Name: 'common.Slider',
	Properties: {
		MaxState: {
			Type: 'object',
			Access: 'GETSET'
		},
		MinState: {
			Type: 'object',
			Access: 'GETSET'
		},
		Speed:{}
	},
	Events: {
		onResize: {}
	},
	Contents:{
		content:{}
	}
});
// -----------------------------------------------
